home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / cblas / test_gemv.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-18  |  12.8 KB  |  504 lines

  1. #include <gsl/gsl_test.h>
  2. #include <gsl/gsl_ieee_utils.h>
  3. #include <gsl/gsl_math.h>
  4. #include <gsl/gsl_cblas.h>
  5.  
  6. #include "tests.h"
  7.  
  8. void
  9. test_gemv (void) {
  10. const double flteps = 1e-4, dbleps = 1e-6;
  11.   {
  12.    int order = 101;
  13.    int trans = 111;
  14.    int M = 1;
  15.    int N = 1;
  16.    int lda = 1;
  17.    float alpha = 1.0f;
  18.    float beta = -0.3f;
  19.    float A[] = { -0.805f };
  20.    float X[] = { -0.965f };
  21.    int incX = -1;
  22.    float Y[] = { 0.537f };
  23.    int incY = -1;
  24.    float y_expected[] = { 0.615725f };
  25.    cblas_sgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  26.    {
  27.      int i;
  28.      for (i = 0; i < 1; i++) {
  29.        gsl_test_rel(Y[i], y_expected[i], flteps, "sgemv(case 774)");
  30.      }
  31.    };
  32.   };
  33.  
  34.  
  35.   {
  36.    int order = 102;
  37.    int trans = 111;
  38.    int M = 1;
  39.    int N = 1;
  40.    int lda = 1;
  41.    float alpha = 1.0f;
  42.    float beta = -0.3f;
  43.    float A[] = { -0.805f };
  44.    float X[] = { -0.965f };
  45.    int incX = -1;
  46.    float Y[] = { 0.537f };
  47.    int incY = -1;
  48.    float y_expected[] = { 0.615725f };
  49.    cblas_sgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  50.    {
  51.      int i;
  52.      for (i = 0; i < 1; i++) {
  53.        gsl_test_rel(Y[i], y_expected[i], flteps, "sgemv(case 775)");
  54.      }
  55.    };
  56.   };
  57.  
  58.  
  59.   {
  60.    int order = 101;
  61.    int trans = 112;
  62.    int M = 1;
  63.    int N = 1;
  64.    int lda = 1;
  65.    float alpha = 1.0f;
  66.    float beta = 0.0f;
  67.    float A[] = { -0.805f };
  68.    float X[] = { -0.965f };
  69.    int incX = -1;
  70.    float Y[] = { 0.537f };
  71.    int incY = -1;
  72.    float y_expected[] = { 0.776825f };
  73.    cblas_sgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  74.    {
  75.      int i;
  76.      for (i = 0; i < 1; i++) {
  77.        gsl_test_rel(Y[i], y_expected[i], flteps, "sgemv(case 776)");
  78.      }
  79.    };
  80.   };
  81.  
  82.  
  83.   {
  84.    int order = 102;
  85.    int trans = 112;
  86.    int M = 1;
  87.    int N = 1;
  88.    int lda = 1;
  89.    float alpha = 1.0f;
  90.    float beta = 0.0f;
  91.    float A[] = { -0.805f };
  92.    float X[] = { -0.965f };
  93.    int incX = -1;
  94.    float Y[] = { 0.537f };
  95.    int incY = -1;
  96.    float y_expected[] = { 0.776825f };
  97.    cblas_sgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  98.    {
  99.      int i;
  100.      for (i = 0; i < 1; i++) {
  101.        gsl_test_rel(Y[i], y_expected[i], flteps, "sgemv(case 777)");
  102.      }
  103.    };
  104.   };
  105.  
  106.  
  107.   {
  108.    int order = 101;
  109.    int trans = 111;
  110.    int M = 1;
  111.    int N = 1;
  112.    int lda = 1;
  113.    double alpha = -0.3;
  114.    double beta = -1;
  115.    double A[] = { -0.047 };
  116.    double X[] = { 0.672 };
  117.    int incX = -1;
  118.    double Y[] = { 0.554 };
  119.    int incY = -1;
  120.    double y_expected[] = { -0.5445248 };
  121.    cblas_dgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  122.    {
  123.      int i;
  124.      for (i = 0; i < 1; i++) {
  125.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dgemv(case 778)");
  126.      }
  127.    };
  128.   };
  129.  
  130.  
  131.   {
  132.    int order = 102;
  133.    int trans = 111;
  134.    int M = 1;
  135.    int N = 1;
  136.    int lda = 1;
  137.    double alpha = -0.3;
  138.    double beta = -1;
  139.    double A[] = { -0.047 };
  140.    double X[] = { 0.672 };
  141.    int incX = -1;
  142.    double Y[] = { 0.554 };
  143.    int incY = -1;
  144.    double y_expected[] = { -0.5445248 };
  145.    cblas_dgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  146.    {
  147.      int i;
  148.      for (i = 0; i < 1; i++) {
  149.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dgemv(case 779)");
  150.      }
  151.    };
  152.   };
  153.  
  154.  
  155.   {
  156.    int order = 101;
  157.    int trans = 112;
  158.    int M = 1;
  159.    int N = 1;
  160.    int lda = 1;
  161.    double alpha = -1;
  162.    double beta = 1;
  163.    double A[] = { -0.047 };
  164.    double X[] = { 0.672 };
  165.    int incX = -1;
  166.    double Y[] = { 0.554 };
  167.    int incY = -1;
  168.    double y_expected[] = { 0.585584 };
  169.    cblas_dgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  170.    {
  171.      int i;
  172.      for (i = 0; i < 1; i++) {
  173.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dgemv(case 780)");
  174.      }
  175.    };
  176.   };
  177.  
  178.  
  179.   {
  180.    int order = 102;
  181.    int trans = 112;
  182.    int M = 1;
  183.    int N = 1;
  184.    int lda = 1;
  185.    double alpha = -1;
  186.    double beta = 1;
  187.    double A[] = { -0.047 };
  188.    double X[] = { 0.672 };
  189.    int incX = -1;
  190.    double Y[] = { 0.554 };
  191.    int incY = -1;
  192.    double y_expected[] = { 0.585584 };
  193.    cblas_dgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  194.    {
  195.      int i;
  196.      for (i = 0; i < 1; i++) {
  197.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dgemv(case 781)");
  198.      }
  199.    };
  200.   };
  201.  
  202.  
  203.   {
  204.    int order = 101;
  205.    int trans = 111;
  206.    int M = 1;
  207.    int N = 1;
  208.    int lda = 1;
  209.    float alpha[2] = {0.0f, 0.1f};
  210.    float beta[2] = {0.0f, 1.0f};
  211.    float A[] = { 0.629f, 0.801f };
  212.    float X[] = { 0.778f, -0.073f };
  213.    int incX = -1;
  214.    float Y[] = { -0.976f, -0.682f };
  215.    int incY = -1;
  216.    float y_expected[] = { 0.624274f, -0.921216f };
  217.    cblas_cgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  218.    {
  219.      int i;
  220.      for (i = 0; i < 1; i++) {
  221.        gsl_test_rel(Y[2*i], y_expected[2*i], flteps, "cgemv(case 782) real");
  222.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], flteps, "cgemv(case 782) imag");
  223.      };
  224.    };
  225.   };
  226.  
  227.  
  228.   {
  229.    int order = 102;
  230.    int trans = 111;
  231.    int M = 1;
  232.    int N = 1;
  233.    int lda = 1;
  234.    float alpha[2] = {0.0f, 0.1f};
  235.    float beta[2] = {0.0f, 1.0f};
  236.    float A[] = { 0.629f, 0.801f };
  237.    float X[] = { 0.778f, -0.073f };
  238.    int incX = -1;
  239.    float Y[] = { -0.976f, -0.682f };
  240.    int incY = -1;
  241.    float y_expected[] = { 0.624274f, -0.921216f };
  242.    cblas_cgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  243.    {
  244.      int i;
  245.      for (i = 0; i < 1; i++) {
  246.        gsl_test_rel(Y[2*i], y_expected[2*i], flteps, "cgemv(case 783) real");
  247.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], flteps, "cgemv(case 783) imag");
  248.      };
  249.    };
  250.   };
  251.  
  252.  
  253.   {
  254.    int order = 101;
  255.    int trans = 112;
  256.    int M = 1;
  257.    int N = 1;
  258.    int lda = 1;
  259.    float alpha[2] = {0.0f, 1.0f};
  260.    float beta[2] = {-0.3f, 0.1f};
  261.    float A[] = { 0.629f, 0.801f };
  262.    float X[] = { 0.778f, -0.073f };
  263.    int incX = -1;
  264.    float Y[] = { -0.976f, -0.682f };
  265.    int incY = -1;
  266.    float y_expected[] = { -0.216261f, 0.654835f };
  267.    cblas_cgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  268.    {
  269.      int i;
  270.      for (i = 0; i < 1; i++) {
  271.        gsl_test_rel(Y[2*i], y_expected[2*i], flteps, "cgemv(case 784) real");
  272.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], flteps, "cgemv(case 784) imag");
  273.      };
  274.    };
  275.   };
  276.  
  277.  
  278.   {
  279.    int order = 102;
  280.    int trans = 112;
  281.    int M = 1;
  282.    int N = 1;
  283.    int lda = 1;
  284.    float alpha[2] = {0.0f, 1.0f};
  285.    float beta[2] = {-0.3f, 0.1f};
  286.    float A[] = { 0.629f, 0.801f };
  287.    float X[] = { 0.778f, -0.073f };
  288.    int incX = -1;
  289.    float Y[] = { -0.976f, -0.682f };
  290.    int incY = -1;
  291.    float y_expected[] = { -0.216261f, 0.654835f };
  292.    cblas_cgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  293.    {
  294.      int i;
  295.      for (i = 0; i < 1; i++) {
  296.        gsl_test_rel(Y[2*i], y_expected[2*i], flteps, "cgemv(case 785) real");
  297.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], flteps, "cgemv(case 785) imag");
  298.      };
  299.    };
  300.   };
  301.  
  302.  
  303.   {
  304.    int order = 101;
  305.    int trans = 113;
  306.    int M = 1;
  307.    int N = 1;
  308.    int lda = 1;
  309.    float alpha[2] = {0.0f, 0.1f};
  310.    float beta[2] = {-0.3f, 0.1f};
  311.    float A[] = { 0.629f, 0.801f };
  312.    float X[] = { 0.778f, -0.073f };
  313.    int incX = -1;
  314.    float Y[] = { -0.976f, -0.682f };
  315.    int incY = -1;
  316.    float y_expected[] = { 0.427909f, 0.150089f };
  317.    cblas_cgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  318.    {
  319.      int i;
  320.      for (i = 0; i < 1; i++) {
  321.        gsl_test_rel(Y[2*i], y_expected[2*i], flteps, "cgemv(case 786) real");
  322.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], flteps, "cgemv(case 786) imag");
  323.      };
  324.    };
  325.   };
  326.  
  327.  
  328.   {
  329.    int order = 102;
  330.    int trans = 113;
  331.    int M = 1;
  332.    int N = 1;
  333.    int lda = 1;
  334.    float alpha[2] = {0.0f, 0.1f};
  335.    float beta[2] = {-0.3f, 0.1f};
  336.    float A[] = { 0.629f, 0.801f };
  337.    float X[] = { 0.778f, -0.073f };
  338.    int incX = -1;
  339.    float Y[] = { -0.976f, -0.682f };
  340.    int incY = -1;
  341.    float y_expected[] = { 0.427909f, 0.150089f };
  342.    cblas_cgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  343.    {
  344.      int i;
  345.      for (i = 0; i < 1; i++) {
  346.        gsl_test_rel(Y[2*i], y_expected[2*i], flteps, "cgemv(case 787) real");
  347.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], flteps, "cgemv(case 787) imag");
  348.      };
  349.    };
  350.   };
  351.  
  352.  
  353.   {
  354.    int order = 101;
  355.    int trans = 111;
  356.    int M = 1;
  357.    int N = 1;
  358.    int lda = 1;
  359.    double alpha[2] = {0, 0.1};
  360.    double beta[2] = {1, 0};
  361.    double A[] = { 0.932, -0.724 };
  362.    double X[] = { 0.334, -0.317 };
  363.    int incX = -1;
  364.    double Y[] = { 0.348, 0.07 };
  365.    int incY = -1;
  366.    double y_expected[] = { 0.401726, 0.078178 };
  367.    cblas_zgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  368.    {
  369.      int i;
  370.      for (i = 0; i < 1; i++) {
  371.        gsl_test_rel(Y[2*i], y_expected[2*i], dbleps, "zgemv(case 788) real");
  372.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], dbleps, "zgemv(case 788) imag");
  373.      };
  374.    };
  375.   };
  376.  
  377.  
  378.   {
  379.    int order = 102;
  380.    int trans = 111;
  381.    int M = 1;
  382.    int N = 1;
  383.    int lda = 1;
  384.    double alpha[2] = {0, 0.1};
  385.    double beta[2] = {1, 0};
  386.    double A[] = { 0.932, -0.724 };
  387.    double X[] = { 0.334, -0.317 };
  388.    int incX = -1;
  389.    double Y[] = { 0.348, 0.07 };
  390.    int incY = -1;
  391.    double y_expected[] = { 0.401726, 0.078178 };
  392.    cblas_zgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  393.    {
  394.      int i;
  395.      for (i = 0; i < 1; i++) {
  396.        gsl_test_rel(Y[2*i], y_expected[2*i], dbleps, "zgemv(case 789) real");
  397.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], dbleps, "zgemv(case 789) imag");
  398.      };
  399.    };
  400.   };
  401.  
  402.  
  403.   {
  404.    int order = 101;
  405.    int trans = 112;
  406.    int M = 1;
  407.    int N = 1;
  408.    int lda = 1;
  409.    double alpha[2] = {-0.3, 0.1};
  410.    double beta[2] = {0, 1};
  411.    double A[] = { 0.932, -0.724 };
  412.    double X[] = { 0.334, -0.317 };
  413.    int incX = -1;
  414.    double Y[] = { 0.348, 0.07 };
  415.    int incY = -1;
  416.    double y_expected[] = { -0.040808, 0.517356 };
  417.    cblas_zgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  418.    {
  419.      int i;
  420.      for (i = 0; i < 1; i++) {
  421.        gsl_test_rel(Y[2*i], y_expected[2*i], dbleps, "zgemv(case 790) real");
  422.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], dbleps, "zgemv(case 790) imag");
  423.      };
  424.    };
  425.   };
  426.  
  427.  
  428.   {
  429.    int order = 102;
  430.    int trans = 112;
  431.    int M = 1;
  432.    int N = 1;
  433.    int lda = 1;
  434.    double alpha[2] = {-0.3, 0.1};
  435.    double beta[2] = {0, 1};
  436.    double A[] = { 0.932, -0.724 };
  437.    double X[] = { 0.334, -0.317 };
  438.    int incX = -1;
  439.    double Y[] = { 0.348, 0.07 };
  440.    int incY = -1;
  441.    double y_expected[] = { -0.040808, 0.517356 };
  442.    cblas_zgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  443.    {
  444.      int i;
  445.      for (i = 0; i < 1; i++) {
  446.        gsl_test_rel(Y[2*i], y_expected[2*i], dbleps, "zgemv(case 791) real");
  447.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], dbleps, "zgemv(case 791) imag");
  448.      };
  449.    };
  450.   };
  451.  
  452.  
  453.   {
  454.    int order = 101;
  455.    int trans = 113;
  456.    int M = 1;
  457.    int N = 1;
  458.    int lda = 1;
  459.    double alpha[2] = {1, 0};
  460.    double beta[2] = {0, 0};
  461.    double A[] = { 0.932, -0.724 };
  462.    double X[] = { 0.334, -0.317 };
  463.    int incX = -1;
  464.    double Y[] = { 0.348, 0.07 };
  465.    int incY = -1;
  466.    double y_expected[] = { 0.540796, -0.053628 };
  467.    cblas_zgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  468.    {
  469.      int i;
  470.      for (i = 0; i < 1; i++) {
  471.        gsl_test_rel(Y[2*i], y_expected[2*i], dbleps, "zgemv(case 792) real");
  472.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], dbleps, "zgemv(case 792) imag");
  473.      };
  474.    };
  475.   };
  476.  
  477.  
  478.   {
  479.    int order = 102;
  480.    int trans = 113;
  481.    int M = 1;
  482.    int N = 1;
  483.    int lda = 1;
  484.    double alpha[2] = {1, 0};
  485.    double beta[2] = {0, 0};
  486.    double A[] = { 0.932, -0.724 };
  487.    double X[] = { 0.334, -0.317 };
  488.    int incX = -1;
  489.    double Y[] = { 0.348, 0.07 };
  490.    int incY = -1;
  491.    double y_expected[] = { 0.540796, -0.053628 };
  492.    cblas_zgemv(order, trans, M, N, alpha, A, lda, X,                                  incX, beta, Y, incY);
  493.    {
  494.      int i;
  495.      for (i = 0; i < 1; i++) {
  496.        gsl_test_rel(Y[2*i], y_expected[2*i], dbleps, "zgemv(case 793) real");
  497.        gsl_test_rel(Y[2*i+1], y_expected[2*i+1], dbleps, "zgemv(case 793) imag");
  498.      };
  499.    };
  500.   };
  501.  
  502.  
  503. }
  504.